/* 	Replication code.
	Paper: The Rule of Law, Collective Action, and Growth: Micro Evidence from Peru.
	Authors: Keefer, Espinoza, Espinoza, Fort.
	Journal: Economic Development and Cultural Change. (2025)
	*/

* Packages to install:
	* ACTION REQUIRED: uncomment relevant packages.
		* ssc install parmest, replace
		* ssc instal  ivreg2, replace
		* ssc install ranktest, replace
		* ssc install texdoc, replace

********************************************************************************
* Set Relevant Globals:											   			   *
********************************************************************************
* Folder paths:
	global mainpath		"...\KEEF2025" // ACTION REQUIRED: location where replication folder is saved
	global temporales   "$mainpath\data"
	global codigo   	"$mainpath\code"
	global tablas   	"$mainpath\output\tab"
	global figuras 		"$mainpath\output\fig"
		
* Set the relevant controls:
	glo vendor_controls 			edad edu_nivel fundador nac_fuera
	glo market_controls 			puestos antiguedad p_funda p_verdura p_fruta p_carne p_ave p_pes p_abar indsuper indmdos17
	glo market_vars 				vecFIN enf_form ${market_controls}
	glo market_vars_excl_shares 	vecFIN enf_form puestos antiguedad p_funda indmdos17 indsuper // This global excludes p_verdura p_fruta p_carne p_ave p_pes p_abar
	glo shares 						p_verdura p_fruta p_carne p_ave p_pes p_abar
	
* Define macros of controls and variables of interest
	global ties		"vecFIN"
	global cli      "dln_clis"
	global clu      "codmerc"
	global bp       "VarBPcomplex"
	global bp07     "Bpcomplex_2007"
	global cord     "cump_co"
	global nser     "nserv"
	global enf 		"enf_form"
	global enf2     "enf_formS"
	global mdo  	"p_funda indsuper indmdos17 antiguedad puestos p_verdura p_fruta p_carne p_ave p_abar"
	global ven  	"Pollo Carnes Frutas Verduras Abarrotes edu_nivel edad fundador otro_puesto m2_puesto hombre nac_fuera"
	global ven2		"Medad Mfundador Mnac_fuera Medu_nivel " 

* Standard errors computation method:	
	glo vce 	"cluster(codmerc)"
		
********************************************************************************
* DESCRIPTIVE STATS (Tables 1-3):											   *
********************************************************************************
	do "$codigo\1. descriptives.do"
	
********************************************************************************
* MAIN ANALYSES (Tables 4-8 + Figure 2 + Table A1)						   	   *
********************************************************************************
	do "$codigo\2. analyses.do"
	
********************************************************************************
* APPENDIX ANALYSES (Tables A2-A4):											   *
********************************************************************************
	do "$codigo\3. appendix.do"

* End of 0. main.do